<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>配餐配货管理-配餐管理-新增配餐</title>
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<link href="/apply_assets/assets/css/bootstrap.min.css" rel="stylesheet">
	<link href="/apply_assets/assets/css/style.css" rel="stylesheet">
	<link href="/apply_assets/assets/css/font-awesome.css" rel="stylesheet">
  <link rel="stylesheet" href="/plugins/SweetAlert/sweetalert.css" />
</head>
<body>
	<div class="container-fluid">
		<div class="om-ctl-mes">
			<div class="title">
				<div class="col-xs-12"><span class="fa fa-list-ul"> 配餐/配货管理</span><b class="fa fa-caret-right"></b><i><a href="../配餐配货管理-配餐管理.html">配餐管理</a></i><b class="fa fa-caret-right"></b><i>新增配餐</i></div>
			</div>
      <form method="post" enctype="multipart/form-data" name="cater">
      <div class="seltemple">
        <div class="col-xs-12">
           <div class="col-xs-3 peican-time newpei-time"><label>配餐时间</label><input type="text"  readonly="readonly" name="startcreated" id="startdatetime" placeholder="开始时间" value="<?=$tDates['0']?>" onclick="WdatePicker();"><span></span><input type="text" readonly="readonly" id="enddatetime" placeholder="结束时间" value="<?=$tDates[6]?>" onclick="WdatePicker();" disabled="true"/><input type="hidden" name="endcreated" value="<?=$tDates[6]?>"></div>  

          <div class="col-xs-3 mes-btn off-btn"><button type="button" id="save">保存</button><button type="reset">取消</button></div>
        </div>
      </div>

            <div class="personset-content col-xs-12">
              <table class="table table-bordered table-newpei">
                     <tbody>
                      <!-- 周一 -->
                       <tr>
                         <td>周一<br><?=$tDates[0]?><input type="hidden" name="datetime0" value="<?=$tDates[0]?>"></td>
                         <td>
                          <p><label>早上配餐</label><button type="button" onclick="addb(0)">+</button><input type="text" name="breakfast0[]" id='break0'></p>
                          <p><label>中午配餐</label><button type="button" onclick="addl(0)">+</button><input type="text" id='lunch0' name="lunch0[]"></p>
                          <p><label>晚上配餐</label><button type="button" onclick="addd(0)">+</button><input type="text" id="dinner0" name="dinner0[]"></p>
                          <p><label>其他配餐</label><button type="button" onclick="add(0)">+</button><input type="text" id="other0" name="other0[]"></p>
                        </td>
                        </tr>
                      <!--  周二 -->
                        <tr>
                         <td>周二<br><?=$tDates[1]?><input type="hidden" name="datetime1" value="<?=$tDates[1]?>"></td>
                         <td>
                          <p><label>早上配餐</label><button type="button" onclick="addb(1)">+</button><input type="text" name="breakfast1[]" id='break1'></p>
                          <p><label>中午配餐</label><button type="button" onclick="addl(1)">+</button><input type="text" id='lunch1' name="lunch1[]"></p>
                          <p><label>晚上配餐</label><button type="button" onclick="addd(1)">+</button><input type="text" id="dinner1" name="dinner1[]"></p>
                          <p><label>其他配餐</label><button type="button" onclick="add(1)">+</button><input type="text" id="other1" name="other1[]"></p>
                        </td>
                        </tr>
                      <!-- 周三 -->
                       <tr>
                         <td>周三<br><?=$tDates[2]?><input type="hidden" name="datetime2" value="<?=$tDates[2]?>"></td>
                         <td>
                          <p><label>早上配餐</label><button type="button" onclick="addb(2)">+</button><input type="text" name="breakfast2[]" id='break2'></p>
                          <p><label>中午配餐</label><button type="button" onclick="addl(2)">+</button><input type="text" id='lunch2' name="lunch2[]"></p>
                          <p><label>晚上配餐</label><button type="button" onclick="addd(2)">+</button><input type="text" id="dinner2" name="dinner2[]"></p>
                          <p><label>其他配餐</label><button type="button" onclick="add(2)">+</button><input type="text" id="other2" name="other2[]"></p>
                        </td>
                        </tr>
                      <!-- 周四 -->
                         <tr>
                         <td>周四<br><?=$tDates[3]?><input type="hidden" name="datetime3" value="<?=$tDates[3]?>"></td>
                         <td>
                          <p><label>早上配餐</label><button type="button" onclick="addb(3)">+</button><input type="text" name="breakfast3[]" id='break3'></p>
                          <p><label>中午配餐</label><button type="button" onclick="addl(3)">+</button><input type="text" id='lunch3' name="lunch3[]"></p>
                          <p><label>晚上配餐</label><button type="button" onclick="addd(3)">+</button><input type="text" id="dinner3" name="dinner3[]"></p>
                          <p><label>其他配餐</label><button type="button" onclick="add(3)">+</button><input type="text" id="other3" name="other3[]"></p>
                        </td>
                        </tr>
                      <!-- 周五 -->
                        <tr>
                         <td>周五<br><?=$tDates[4]?><input type="hidden" name="datetime4" value="<?=$tDates[4]?>"></td>
                         <td>
                          <p><label>早上配餐</label><button type="button" onclick="addb(4)">+</button><input type="text" name="breakfast4[]" id='break4'></p>
                          <p><label>中午配餐</label><button type="button" onclick="addl(4)">+</button><input type="text" id='lunch4' name="lunch4[]"></p>
                          <p><label>晚上配餐</label><button type="button" onclick="addd(4)">+</button><input type="text" id="dinner4" name="dinner4[]"></p>
                          <p><label>其他配餐</label><button type="button" onclick="add(4)">+</button><input type="text" id="other4" name="other4[]"></p>
                        </td>
                        </tr>
                      <!-- 周六 -->
                      <tr>
                         <td>周六<br><?=$tDates[5]?><input type="hidden" name="datetime5" value="<?=$tDates[5]?>"></td>
                         <td>
                          <p><label>早上配餐</label><button type="button" onclick="addb(5)">+</button><input type="text" name="breakfast5[]" id='break5'></p>
                          <p><label>中午配餐</label><button type="button" onclick="addl(5)">+</button><input type="text" id='lunch5' name="lunch5[]"></p>
                          <p><label>晚上配餐</label><button type="button" onclick="addd(5)">+</button><input type="text" id="dinner5" name="dinner5[]"></p>
                          <p><label>其他配餐</label><button type="button" onclick="add(5)">+</button><input type="text" id="other5" name="other5[]"></p>
                        </td>
                        </tr>
                      <!-- 周日 -->
                        <tr>
                         <td>周日<br><?=$tDates[6]?><input type="hidden" name="datetime6" value="<?=$tDates[6]?>"></td>
                         <td>
                          <p><label>早上配餐</label><button type="button" onclick="addb(6)">+</button><input type="text" name="breakfast6[]" id='break6'></p>
                          <p><label>中午配餐</label><button type="button" onclick="addl(6)">+</button><input type="text" id='lunch6' name="lunch6[]"></p>
                          <p><label>晚上配餐</label><button type="button" onclick="addd(6)">+</button><input type="text" id="dinner6" name="dinner6[]"></p>
                          <p><label>其他配餐</label><button type="button" onclick="add(6)">+</button><input type="text" id="other6" name="other6[]" ></p>
                        </td>
                        </tr>
                     </tbody>
                 </table>
                  </div>  
                  </form>         
		</div>	
    </div>
  </div>
    <script type="text/javascript" src="/apply_assets/assets/js/jquery.min.js"></script>
     <script type="text/javascript" src="/apply_assets/assets/js/personset-jq.js"></script>
     <script src="/plugins/SweetAlert/sweetalert.min.js"></script><!--alert插件-->
      <script src="/js/jquery.form.js"></script><!--form表单插件-->
      <script type="text/javascript" src="/plugins/datepicker/WdatePicker.js" charset="UTF-8"></script>
     <script type="text/javascript" >
     function addb(i){
      var addhtml = '<span class="delinput"><input type="text" name="breakfast'+i+'[]"><img src="/apply_assets/assets/img/del_03.png"  onclick="imgdel($(this).parent().remove())"></span>'
      $('#break'+i).after(addhtml);
     }
    function addl(i){
      var addhtml = '<span class="delinput"><input type="text" name="lunch'+i+'[]"><img src="/apply_assets/assets/img/del_03.png"  onclick="imgdel($(this).parent().remove())"></span>'
      $('#lunch'+i).after(addhtml);
     }
    function addd(i){
      var addhtml = '<span class="delinput"><input type="text" name="dinner'+i+'[]"><img src="/apply_assets/assets/img/del_03.png" onclick="imgdel($(this).parent().remove())"></span>'
      $('#dinner'+i).after(addhtml);
     }
      function add(i){
      var addhtml = '<span class="delinput"><input type="text" name="other'+i+'[]"><img src="/apply_assets/assets/img/del_03.png" onclick="imgdel($(this).parent().remove())"></span>'
      $('#other'+i).after(addhtml);
     }
     $('.imgdel').bind('click',function(){
      $(this).parent().remove();
     })
     function imgdel(){}
    $('#save').click(function(){
        // $('#enddatetime').removeAttr('disabled');
        var data = $('form[name="cater"]').serialize();
        // alert(data);
        $.post('/admin_cater/add',data,function(obj){
            cg_alert_add(obj,'/admin_cater/','/admin_cater/add');
            // $('#enddatetime').attr('disabled',true);
        });
    });
function cg_alert_add(obj,list_url,add_url){
    if(obj.status == 1){
        swal({
            title: obj.msg,
            confirmButtonText:'继续添加',
            confirmButtonColor: "#DD6B55",
            showCancelButton: true,
            cancelButtonText:'返回列表',
            type: "success",
        },function(isConfirm){
            if (isConfirm) {
                location.href = add_url;
            }else{
                location.href = list_url;
            }
        });
    }else{
        swal(obj.msg,'','error');
    }

}
function cg_alert_edit(obj,list_url,edit_url){
    if(obj.status == 1){
        swal({
            title: obj.msg,
            confirmButtonText:'继续修改',
            confirmButtonColor: "#DD6B55",
            showCancelButton: true,
            cancelButtonText:'返回列表',
            type: "success",
        },function(isConfirm){
            if (isConfirm) {
                location.href = edit_url;
            }else{
                location.href = list_url;
            }
        });
    }else{
        swal(obj.msg,'','error');
    }

}
function cg_confirm_del(del_url,jump_url){
    swal({
            title: '您确定要删除吗？',
            text:'删除之后不能恢复',
            type: "warning",
            showCancelButton: true,
            confirmButtonColor: "#DD6B55",
            confirmButtonText:'确定',
            closeOnConfirm: false,
            cancelButtonText:'取消'
        },
        function(isConfirm){
            if(isConfirm){
                window.obj = '';
                $.ajax({
                    url: del_url,
                    dataType: "json",
                    async:false,
                    success: function (obj) {
                        window.obj = obj;
                    }
                });

                if(window.obj.status == 1){
                    swal({title:"删除成功!", type:"success"},function(){
                        location.href = jump_url;
                    });
                }else{
                    swal({title:window.obj.msg, type:"error"});
                }
            }
        });
}
</script>
    
</body>
</html>